// import {server} from '@/config/index'
// import ReconnectingWebSocket from "reconnecting-websocket";
// import definePeerStore from '@/stores/peer'
// export default {
//     install(app) {
//         console.log("invoked initialize websocket plugin");
//         app.config.globalProperties.$initializePeer?.then(() => {
//             let peerStore = definePeerStore();
//             let friendStore = useFriendStore();
//
//             let {host, port, path} = server.webSocketServer;
//
//             let connection = new ReconnectingWebSocket(`ws://${host}:${port}${path}/${peerStore.localPeer.id}`);
//
//             connection.onmessage = event => {
//                 let message = JSON.parse(event.data);
//                 friendStore.onlineList = message;
//                 console.log("webSocketConnection.onmessage:", message);
//             };
//
//             connection.onclose = event => {
//                 console.log("webSocketConnection.onclose:", event);
//                 showToast("network connection closed");
//             };
//
//             connection.onerror = event => {
//                 console.log("webSocketConnection.onerror:", event);
//                 showToast("network connection error");
//             };
//
//             connection.onopen = event => {
//                 console.log("webSocketConnection.onopen:", event);
//             };
//         });
//     }
// };